package net.model.command;

public class CommandReciver {

	private ICommand onCommand = null;
	private ICommand offCommand = null;
	private ICommand preCommand = null;
	
	public void setCommand(ICommand onCommand, ICommand offCommand) {
		this.onCommand = onCommand;
		this.offCommand = offCommand;
	}
	
	public int executeOn() {
		if (null==this.onCommand)
			return -1;
		
		preCommand = this.onCommand;
		return this.onCommand.execute();
	}
	
	public int executeOff() {
		if (null==this.offCommand)
			return -1;
		
		preCommand = this.offCommand;
		return this.offCommand.execute();
	}
	
	public void undoCommand() {
		if (null!=this.preCommand)
			this.preCommand.undo();
	}
}
